(function (lib, config) {
    var loadFunc = function () {
        var imglinkAry = config.imglink.split('|');

        imglinkAry[0] = imglinkAry[0] || 'http://rlm.zzgkyy120.com/images/invite_share.gif';
        imglinkAry[1] = imglinkAry[1] || 'http://rlm.zzgkyy120.com/images/right_zxzxs.gif';
        function level() {
            var oBox = document.getElementById('box');
            var oH2 = oBox.getElementsByTagName('span')[0];
            var oBox2 = document.getElementById('box2');
            oBox.style.display = 'block';
            oBox2.style.display = 'none';
            oH2.onclick = function () {
                oBox.style.display = 'none';
                oBox2.style.display = 'block';
                setTimeout(function () {
                    oBoxblock();
                }, config.relapsetime * 1000);
            };
        }
        function oBoxblock() {
            oBox = document.getElementById('box');
            oBox2 = document.getElementById('box2');
            oBox.style.display = 'block';
            oBox2.style.display = 'none';
        }
        thisURL = document.URL;
        setTimeout(function () { level(); }, config.firsttime * 1000);
        function getScrollTop() {
            var scrollTop = 0;
            if (document.documentElement && document.documentElement.scrollTop) {
                scrollTop = document.documentElement.scrollTop;
            }
            else if (document.body) {
                scrollTop = document.body.scrollTop;
            }
            return scrollTop;
        }
        function getClientHeight() {
            var clientHeight = 0;
            if (document.body.clientHeight && document.documentElement.clientHeight) {
                var clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ?

                    document.body.clientHeight : document.documentElement.clientHeight;
            }
            else {
                var clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ?

                    document.body.clientHeight : document.documentElement.clientHeight;
            }
            return clientHeight;
        }

        var _ua = navigator.userAgent, _ua_text = false, _position = "fixed";
        if (_ua.indexOf('baiduboxapp') > -1) {
            _ua_text = true; _position = "absolute";
        }
        config.width = 250, config.height = 142;
        var strVar = [];
        strVar.push("<style type=\"text\/css\">");/*left:50%;margin:-62px -120px*/
        strVar.push("#box{width:250px;height:142px;position:" + _position + ";"+lib.util.getPosStyle(config)+"; z-index:9999;display:none;}");
        strVar.push("#box img,#box2 img {border:0;}");
        strVar.push("#box span{display:block; width:29px; height:29px; position:absolute;top:0px;left:218px;}");
        strVar.push("#box a{display:block; width:124px; height:38px;}");
        strVar.push("#box em{display:block; width:124px; height:49px; position:absolute;top:102px;left:125px;}");
        strVar.push("#box strong{display:block; width:124px; height:38px; position:absolute;top:95px;left:0px;}");
        strVar.push("#box2{width:30px;position:fixed;right:0px;top:30%;z-index:9999;display:none;background:url(" + imglinkAry[1] + ") left top no-repeat;}");
        strVar.push("#box2 img{display:block;}#box2 img.footer_img{ margin-top:4px;}");
        strVar.push("#box2 a:nth-child(2){display:block; width:26px; padding-right:4px; height:38px; text-align:center; line-height:34px; color:#c63232; font-size:14px;}");
        strVar.push("#box2 a:nth-child(3){display:block; width:30px; height:62px; text-align:center;}");
        strVar.push("#box2 a:nth-child(4){display:block; width:30px; height:59px; text-align:center;}");
        strVar.push("<\/style>");
        strVar.push("<div id=\"box\" style=\"\">");/*top:40%*/
        strVar.push("<span><\/span>");
        strVar.push("<img  src=\"" + imglinkAry[0] + "\" border=\"0\" usemap=\"#Map\"\/>");
        strVar.push("<strong><a href=\"javascript:void\" onClick=\"openZoosUrl();\"></a><\/strong>");
        strVar.push("<em><a href=\"tel:18318237652\"></a><\/em>");
        strVar.push("<\/div>");
        strVar.push("<div id=\"box2\">");
        strVar.push("<span onclick=\"close_r3();return false;\" style=\"position:absolute;right:0px;top:-10px;\"><img border=\"0\" src=\"http://rlm.zzgkyy120.com/images/close.gif\"></span><a href=\"javascript:void\" onClick=\"openZoosUrl();\" id=\"sjs\"><script language=\"javascript\">document.write(Math.floor(Math.random()*20+40)); </script><\/a><a onClick=\"location.href=\'tel:18318237652\'\" ><\/a><a href=\"javascript:void\" onClick=\"openZoosUrl();\"><\/a> ");
        strVar.push("<\/div>");
        var o = document.createElement('div');
        o.innerHTML = strVar.join('');
        while (o.firstElementChild) {
            document.body.appendChild(o.firstElementChild);
        };
        if (_ua_text) {
            var _t = document.getElementById('box').style.top;
            window.onscroll = function () {
                document.getElementById('box').style.top = parseInt(_t) + (getScrollTop() / getClientHeight()) * 100 + '%';
            }
        }
        function close_r2() {
            document.getElementById('box2').style.display = 'none';
        }
    };
    lib.load(loadFunc);
})('{{lib}}', '{{config}}');

